package com.yanqu.road.server.cmd.activity.share;

import com.yanqu.road.pb.activity.ShareProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.share.ShareModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/11/29 15:58
 */
@Cmd(code = GameProtocol.S_ACTIVITY_DEAR_SHARE, desc = "亲友分享")
public class QyfxInviteSuccessCmd extends AbstractCommand {
    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ShareProto.DearShareSuccessReqMsg reqMsg = ShareProto.DearShareSuccessReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ShareModule.class).qyfxInviteSuccess(activityId);
    }

    @Override
    public void sendData(GamePlayer player) {
        ShareProto.DearShareSuccessRespMsg.Builder respMsg = ShareProto.DearShareSuccessRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(ClientProtocol.U_ACTIVITY_DEAR_SHARE, respMsg);
    }
}
